home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
MSGDIR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
14KB
|
359 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 7-23-88 3:57 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit MsgDir;
Interface
Uses
TPCrt, Globals, Core1, NetMisc,
TPSTRING, TPDOS, Core2;
procedure mesg_directory;
{==========================================================================}
Implementation
procedure mesg_directory;
{ Display directory of messages }
type
buftype = array[1..1] of fido_summ_rec;
bufptr = ^buftype;
var
buffer : bufptr;
col_width,
col_count,
col_limit,
conf_num,
msg_high,
msg_total, i : Integer;
record_count : LongInt;
This : AreaPtr;
temstr : string[160];
found,
found_msg_to,
found_msg_from,
wrote_lfcr,
first_pass : Boolean;
ThisP, LastP : NetAreaPtr;
summary_file : untype_file;
begin {msg_directory}
col_width := 6;
abort := False;
col_limit := max(1, user_rec.columns div col_width);
Write(Com, hi);
if (AreaReq[1] <> '-') and (AreaReq <> 'NETMAIL') then
begin
WriteLn(Com, yellow, 'Message numbers, this area : ', msg_lo, '-', msg_hi);
WriteLn(Com, 'Public messages, this area : ', msg_all, cyan);
WriteLn(Com);
if msg_ind = 0 then
WriteLn(Com, yellow, 'No messages addressed to you in this area.', cyan)
else
begin
WriteLn(Com, yellow, 'The following messages are addressed to you:', cyan);
col_count := 0;
MesgCurr := MesgBase;
while (not brk) and (MesgCurr <> nil) do
begin
if MesgCurr^.TypMsg = 1 then
begin
Write(Com, MesgCurr^.MesgNo:col_width);
Inc(col_count);
if (0 = col_count mod col_limit) then
WriteLn(Com)
end;
MesgCurr := MesgCurr^.next
end;
WriteLn(Com)
end;
if msg_aut > 0 then
begin
WriteLn(Com);
WriteLn(Com, yellow, 'The following messages were sent by you:', cyan);
col_count := 0;
MesgCurr := MesgBase;
while (not brk) and (MesgCurr <> nil) do
begin
if MesgCurr^.TypMsg = 2 then
begin
Write(Com, MesgCurr^.MesgNo:col_width);
Inc(col_count);
if (0 = col_count mod col_limit) then
WriteLn(Com)
end;
MesgCurr := MesgCurr^.next
end;
WriteLn(Com);
end;
end
else
begin
if AreaReq = 'NETMAIL' then
FidoArea := fidomail
else
FidoArea := fidomail+'\'+AreaReq;
SetSect(FidoArea);
fido_sort(msg_high, msg_total, msg_numbers);
SetSect(FidoArea);
WriteLn(Com, yellow, 'Message numbers, this area : ', msg_numbers[1], '-', msg_high);
WriteLn(Com, 'Total messages, this area : ', msg_total, cyan);
WriteLn(Com);
if ExistFile('ORIGIN') then
begin
Assign(orig_file, 'ORIGIN');
Reset(orig_file);
ReadLn(orig_file, sect_orig);
sect_orig := ' * Origin: '+sect_orig+' ('+my_zone+':'+my_net+'/'+my_node+')'
+CR+LF;
Close(orig_file);
end
else
sect_orig := orig_line;
if ExistFile(nsum_name+ext) then
begin
Assign(fido_summ_file, nsum_name+ext);
Reset(fido_summ_file);
found_msg_to := False;
if FileSize(fido_summ_file) > 0 then
while (not EoF(fido_summ_file)) and (not found_msg_to) do
begin
Read(fido_summ_file, summary_record);
found_msg_to := (summary_record.to_loc = user_loc);
end;
if (not found_msg_to) then
WriteLn(Com, yellow, 'No messages addressed to you in this area.', cyan)
else
begin
WriteLn(Com, yellow);
WriteLn(Com, 'The following messages are addressed to you:', cyan);
col_count := 0;
Write(Com, summary_record.number:col_width);
Inc(col_count);
while (not EoF(fido_summ_file)) do
begin
Read(fido_summ_file, summary_record);
found_msg_to := (summary_record.to_loc = user_loc);
if found_msg_to then
begin
Write(Com, summary_record.number:col_width);
Inc(col_count);
if (0 = col_count mod col_limit) then
WriteLn(Com)
end;
end;
WriteLn(Com)
end;
Seek(fido_summ_file, 0);
found_msg_from := False;
if FileSize(fido_summ_file) > 0 then
while (not EoF(fido_summ_file)) and (not found_msg_from) do
begin
Read(fido_summ_file, summary_record);
found_msg_from := (summary_record.from_loc = user_loc);
end;
if found_msg_from then
begin
WriteLn(Com, yellow);
WriteLn(Com, 'The following messages were sent by you:', cyan);
col_count := 0;
Write(Com, summary_record.number:col_width);
Inc(col_count);
while (not EoF(fido_summ_file)) do
begin
Read(fido_summ_file, summary_record);
found_msg_from := (summary_record.from_loc = user_loc);
if found_msg_from then
begin
Write(Com, summary_record.number:col_width);
Inc(col_count);
if (0 = col_count mod col_limit) then
WriteLn(Com)
end;
end;
WriteLn(Com)
end;
Close(fido_summ_file);
end;
end;
if UserWantsScan then
begin
first_pass := True;
Seek(summ_file, 1); {look for msgs in other areas}
col_count := 0;
col_width := 12;
temstr := '';
col_limit := max(1, user_rec.columns div col_width);
found := False;
while not EoF(summ_file) do
with summ_rec do
begin
Read(summ_file, summ_rec);
if (status <> deleted) and (Area <> AreaSet) and (user_loc = user_to) then
begin
This := AreaBase;
while (This <> nil) and (This^.Area <> Area) do
This := This^.next;
conf_num := This^.AreaConf and 7;
if (Pos(This^.AreaName, temstr) = 0) and (This <> nil) and ((user_rec.access
>= This^.AreaAccs) or
(test_bit(user_rec.conf_flags, conf_num))) then
begin
wrote_lfcr := False;
if first_pass then
begin
first_pass := False;
WriteLn(Com);
end;
found := True;
Write(Com, This^.AreaName:col_width);
Inc(col_count);
temstr := temstr+This^.AreaName;
if (0 = col_count mod col_limit) then
begin
WriteLn(Com);
wrote_lfcr := True;
end;
end;
end;
end; {reading summary file}
This := AreaBase;
if first_scan then
begin
ThisP := NetAreaBase;
while ThisP <> nil do
begin
LastP := ThisP;
ThisP := ThisP^.next;
Dispose(LastP);
end;
repeat
found_msg_to := False;
while (This <> nil) and (This^.AreaName[1] <> '-') and (This^.AreaName <> 'NETMAIL') do
This := This^.next;
conf_num := This^.AreaConf and 7;
if ((This <> nil) and ((user_rec.access >= This^.AreaAccs) or
(test_bit(user_rec.conf_flags, conf_num)))) and (This^.AreaName <> AreaReq) then
begin
if This^.AreaName = 'NETMAIL' then
FidoArea := fidomail
else
FidoArea := fidomail+'\'+This^.AreaName;
SetSect(FidoArea);
if ExistFile(nsum_name+ext) then
begin
Assign(summary_file, nsum_name+ext);
Reset(summary_file, SizeOf(fido_summ_rec));
record_count := FileSize(summary_file);
GetMem(buffer, record_count*SizeOf(summary_record));
i := 1;
if record_count > 0 then
begin
BlockRead(summary_file, buffer^, record_count);
while (i <= record_count) and (not found_msg_to) do
begin
summary_record := buffer^[i];
Inc(i);
found_msg_to := (summary_record.to_loc = user_loc);
if found_msg_to then
begin
wrote_lfcr := False;
if first_pass then
begin
first_pass := False;
WriteLn(Com);
end;
temstr := This^.AreaName;
if temstr[1] = '-' then
Delete(temstr, 1, 1);
Write(Com, temstr:col_width);
FreeMem(buffer, record_count*SizeOf(summary_record));
New(ThisP);
if NetAreaBase = nil then
NetAreaBase := ThisP
else
LastP^.next := ThisP;
LastP := ThisP;
LastP^.AreaName := temstr;
LastP^.next := nil;
Inc(col_count);
if (0 = col_count mod col_limit) then
begin
WriteLn(Com);
wrote_lfcr := True;
end;
found := True;
end;
end;
if (not found_msg_to) then
FreeMem(buffer, record_count*SizeOf(summary_record));
end;
Close(summary_file);
end;
end;
if this <> nil then This := This^.next;
until This = nil;
end
else
begin
ThisP := NetAreaBase;
while ThisP <> nil do
begin
temstr := ThisP^.AreaName;
if not((Pos(temstr, AreaReq) = 2) or (temstr = AreaReq)) then
begin
wrote_lfcr := False;
if first_pass then
begin
first_pass := False;
WriteLn(Com);
end;
found := True;
Write(Com, temstr:col_width);
Inc(col_count);
if (0 = col_count mod col_limit) then
begin
WriteLn(Com);
wrote_lfcr := True;
end;
end;
ThisP := ThisP^.next;
end;
end;
if found then
begin
if (not wrote_lfcr) then
WriteLn(Com);
WriteLn(Com, yellow, 'Above are other Areas with messages for you.')
end
else if first_scan then
WriteLn(Com, yellow, 'No messages found for you in other areas.');
first_scan := False;
end;
SetSect(HomName);
WriteLn(Com, cyan);
end;
end. { of MSGDIR.PAS}